﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="mis_function_user_log.aspx.cs" Inherits="mis_function_user_log" EnableEventValidation="false" %>

<%@ Register Src="~/UserControls/ucDateTimeList.ascx" TagPrefix="Kerry" TagName="ucDateTimeList" %>
<%@ Register Src="~/UserControls/ucGridViewPager.ascx" TagName="ucGridViewPager" TagPrefix="Kerry" %>
<%@ Register Src="~/UserControls/ucFavorite.ascx" TagName="ucFavorite" TagPrefix="Kerry" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
  <div>
    <table class="ConditionTable">
      <th colspan="2">
        <Kerry:ucFavorite ID="ucFavorite" runat="server" />
        系統使用紀錄
      </th>
      <tr>
        <td>年月 : 
          <%--<Kerry:ucDateTimeList runat="server" ID="txt_start_date" />--%>
          <asp:DropDownList ID="ddlYear_txt_start_date" runat="server">
            <asp:ListItem>2013</asp:ListItem>
            <asp:ListItem>2014</asp:ListItem>
            <asp:ListItem>2015</asp:ListItem>
            <asp:ListItem>2016</asp:ListItem>
            <asp:ListItem>2018</asp:ListItem>
            <asp:ListItem>2019</asp:ListItem>
            <asp:ListItem>2020</asp:ListItem>
          </asp:DropDownList>
          <asp:DropDownList ID="ddlMonth_txt_start_date" runat="server">
            <asp:ListItem>01</asp:ListItem>
            <asp:ListItem>02</asp:ListItem>
            <asp:ListItem>03</asp:ListItem>
            <asp:ListItem>04</asp:ListItem>
            <asp:ListItem>05</asp:ListItem>
            <asp:ListItem>06</asp:ListItem>
            <asp:ListItem>07</asp:ListItem>
            <asp:ListItem>08</asp:ListItem>
            <asp:ListItem>09</asp:ListItem>
            <asp:ListItem>10</asp:ListItem>
            <asp:ListItem>11</asp:ListItem>
            <asp:ListItem>12</asp:ListItem>
          </asp:DropDownList>
          &nbsp;~
          <%--<Kerry:ucDateTimeList runat="server" ID="txt_end_date" />--%>
          <asp:DropDownList ID="ddlYear_txt_end_date" runat="server">
            <asp:ListItem>2013</asp:ListItem>
            <asp:ListItem>2014</asp:ListItem>
            <asp:ListItem>2015</asp:ListItem>
            <asp:ListItem>2016</asp:ListItem>
            <asp:ListItem>2018</asp:ListItem>
            <asp:ListItem>2019</asp:ListItem>
            <asp:ListItem>2020</asp:ListItem>
          </asp:DropDownList>
          <asp:DropDownList ID="ddlMonth_txt_end_date" runat="server">
            <asp:ListItem>01</asp:ListItem>
            <asp:ListItem>02</asp:ListItem>
            <asp:ListItem>03</asp:ListItem>
            <asp:ListItem>04</asp:ListItem>
            <asp:ListItem>05</asp:ListItem>
            <asp:ListItem>06</asp:ListItem>
            <asp:ListItem>07</asp:ListItem>
            <asp:ListItem>08</asp:ListItem>
            <asp:ListItem>09</asp:ListItem>
            <asp:ListItem>10</asp:ListItem>
            <asp:ListItem>11</asp:ListItem>
            <asp:ListItem>12</asp:ListItem>
          </asp:DropDownList>
        </td>
        <td>選單功能 :
          <asp:DropDownList ID="ddl_menu" runat="server" AppendDataBoundItems="True" DataSourceID="SDS_MIS_FUNCTION_AP" DataTextField="FUNCTION_NAME" DataValueField="FUNCTION_ID">
            <asp:ListItem Value="0">全部</asp:ListItem>
          </asp:DropDownList>
          <asp:SqlDataSource ID="SDS_MIS_FUNCTION_AP" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT FUNCTION_ID, FUNCTION_NAME FROM TG.MIS_FUNCTION_AP
WHERE FUNCTION_TYPE='FUNCTION'
ORDER BY FUNCTION_PARENT_ID,FUNCTION_SORT_ORDER"></asp:SqlDataSource>
        </td>
      </tr>
      <tr>
        <td>單位 :                
                <asp:DropDownList ID="ddl_dept" runat="server">
                  <asp:ListItem Value="0">全部</asp:ListItem>
                  <asp:ListItem Value="1">總公司</asp:ListItem>
                  <asp:ListItem Value="2">營級</asp:ListItem>
                  <asp:ListItem Value="3">處部</asp:ListItem>
                  <asp:ListItem Value="4">區級</asp:ListItem>
                  <asp:ListItem Value="5">所級</asp:ListItem>
                </asp:DropDownList>
        </td>
        <td>使用者 : 
              <asp:TextBox ID="txt_loginname_start" runat="server" Width="100"></asp:TextBox>
          <%--<asp:RegularExpressionValidator ID="REV_start" runat="server" Display="Dynamic" ErrorMessage="員編格式有誤"
                        SetFocusOnError="True" ForeColor="Red" ControlToValidate="txt_loginname_start" ValidationExpression="\d{6}" />--%>
                    &nbsp;~ 
              <asp:TextBox ID="txt_loginname_end" runat="server" Width="100"></asp:TextBox>
          <%--  <asp:RegularExpressionValidator ID="REV_end" runat="server" Display="Dynamic" ErrorMessage="員編格式有誤"
                        SetFocusOnError="True" ForeColor="Red" ControlToValidate="txt_loginname_end" ValidationExpression="\d{6}" />--%>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <asp:Button ID="btn_search" runat="server" Text="搜尋" OnClick="btn_search_Click" />
          <asp:Button ID="btn_export" runat="server" Text="畫面匯出" OnClick="btn_search_Click" />
          <asp:Label ID="lbl_message" runat="server" EnableViewState="False" ForeColor="Red"></asp:Label>
        </td>
      </tr>
    </table>

  </div>
  <br />
  <asp:GridView ID="gv_login_log" runat="server" AllowPaging="True"
    AutoGenerateColumns="False" DataSourceID="SDS_MIS_FUNCTION_USER_LOG"
    OnSelectedIndexChanging="gv_login_log_SelectedIndexChanging"
    OnRowDataBound="gv_login_log_RowDataBound" OnPageIndexChanging="gv_login_log_PageIndexChanging">
    <Columns>
      <asp:TemplateField HeaderText="年月" SortExpression="LOGIN_DATE" HeaderStyle-Width="48">
        <ItemTemplate>
          <asp:Label ID="lbl_LOGIN_DATE" runat="server" Text='<%# Bind("LOGIN_DATE") %>'></asp:Label>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="選單功能">
        <ItemTemplate>
          <asp:Label ID="lbl_FUNCTION_ID" runat="server" Text='<%# Bind("FUNCTION_ID") %>' Visible="false" />
          <asp:Label ID="lbl_FUNCTION_NAME" runat="server" />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="單位">
        <ItemTemplate>
          <asp:Label ID="lbl_DEPT_ID" runat="server" Text='<%# Bind("DEPT_ID") %>' Visible="false" />
          <asp:Label ID="lbl_DEPT_NAME" runat="server" />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="使用者" SortExpression="USER_ID">
        <ItemTemplate>
          <asp:Label ID="lbl_USER_ID" runat="server" Text='<%# Bind("USER_ID") %>' Visible="false"></asp:Label>
          <asp:Label ID="lbl_user_name" runat="server" />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="LOGIN_COUNTER" HeaderText="次數" SortExpression="LOGIN_COUNTER" />
      <asp:TemplateField HeaderText="明細" SortExpression="明細" HeaderStyle-Width="48">
        <ItemTemplate>
          <asp:Button ID="btn_detail" runat="server" Text="明細" CommandName="Select" />
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
    <PagerTemplate>
      <Kerry:ucGridViewPager ID="ucPager" runat="server" />
    </PagerTemplate>
  </asp:GridView>
  <asp:SqlDataSource ID="SDS_MIS_FUNCTION_USER_LOG" runat="server"
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
    SelectCommand="SELECT USER_ID ,FUNCTION_ID,DEPT_ID,  SUBSTR(LOGIN_DATE,0,6) AS LOGIN_DATE , COUNT(USER_ID) AS LOGIN_COUNTER 
FROM MIS_FUNCTION_USER_LOG
GROUP BY USER_ID,FUNCTION_ID,DEPT_ID,  SUBSTR(LOGIN_DATE,0,6)  HAVING 1=1 "
    OnSelecting="SDS_MIS_FUNCTION_USER_LOG_Selecting"></asp:SqlDataSource>
</asp:Content>

